當前位置: 首頁>>代碼示例>>Java>>正文


Java Event類代碼示例

本文整理匯總了Java中edu.mit.csail.sdg.alloy4.Listener.Event的典型用法代碼示例。如果您正苦於以下問題:Java Event類的具體用法?Java Event怎麽用?Java Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Event類屬於edu.mit.csail.sdg.alloy4.Listener包,在下文中一共展示了Event類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: select

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/**
 * Switch to the i-th tab (Note: if successful, it will always send
 * STATUS_CHANGE to the registered listeners.
 */
private void select(int i) {
	if (i < 0 || i >= tabs.size())
		return;
	else {
		me = i;
		component.revalidate();
		adjustLabelColor();
		component.removeAll();
	}
	if (tabs.size() > 1)
		component.add(tabBarScroller, BorderLayout.NORTH);
	tabs.get(me).addTo(component, BorderLayout.CENTER);
	component.repaint();
	tabs.get(me).requestFocusInWindow();
	tabBar.scrollRectToVisible(new Rectangle(0, 0, 0, 0)); // Forces
															// recalculation
	tabBar.scrollRectToVisible(new Rectangle(tabs.get(me).obj2.getX(), 0, tabs.get(me).obj2.getWidth() + 200, 1));
	listeners.fire(this, Event.STATUS_CHANGE);
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:24,代碼來源:OurTabbedSyntaxWidget.java

示例2: shade

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/**
 * Highlights the text editor, based on the location information in the set
 * of Pos objects.
 */
public void shade(Iterable<Pos> set, Color color, boolean clearOldHighlightsFirst) {
	if (clearOldHighlightsFirst)
		clearShade();
	OurSyntaxWidget text = null;
	int c = 0, d;
	for (Pos p : set)
		if (p != null && p.filename.length() > 0 && p.y > 0 && p.x > 0 && newtab(p.filename)) {
			text = get();
			c = text.getLineStartOffset(p.y - 1) + p.x - 1;
			d = text.getLineStartOffset(p.y2 - 1) + p.x2 - 1;
			text.shade(color, c, d + 1);
		}
	if (text != null) {
		text.moveCaret(0, 0);
		text.moveCaret(c, c);
	} // Move to 0 ensures we'll scroll to the highlighted section
	get().requestFocusInWindow();
	adjustLabelColor();
	listeners.fire(this, Event.STATUS_CHANGE);
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:25,代碼來源:OurTabbedSyntaxWidget.java

示例3: load

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/**
 * Discard current content then read the given file; return true if the
 * entire operation succeeds.
 */
boolean load(String filename) {
	String x;
	try {
		x = Util.readAll(filename);
	} catch (Throwable ex) {
		OurDialog.alert("Error reading the file \"" + filename + "\"");
		return false;
	}
	pane.setText(x);
	moveCaret(0, 0);
	clearUndo();
	modified = false;
	isFile = true;
	this.filename = filename;
	listeners.fire(this, Event.STATUS_CHANGE);
	return true;
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:22,代碼來源:OurSyntaxWidget.java

示例4: reload

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/**
 * Discard (after confirming with the user) current content then reread from
 * disk file.
 */
void reload() {
	if (!isFile)
		return; // "untitled" text buffer does not have a on-disk file to
				// refresh from
	if (modified
			&& !OurDialog.yesno(
					"You have unsaved changes to \"" + filename + "\"\nAre you sure you wish to discard "
							+ "your changes and reload it from disk?",
					"Discard your changes", "Cancel this operation"))
		return;
	String t;
	try {
		t = Util.readAll(filename);
	} catch (Throwable ex) {
		OurDialog.alert("Cannot read \"" + filename + "\"");
		return;
	}
	if (modified == false && t.equals(pane.getText()))
		return; // no text change nor status change
	int c = pane.getCaretPosition();
	pane.setText(t);
	moveCaret(c, c);
	modified = false;
	listeners.fire(this, Event.STATUS_CHANGE);
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:30,代碼來源:OurSyntaxWidget.java

示例5: saveAs

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/**
 * Save the current tab content to the file system, and return true if
 * successful.
 */
boolean saveAs(String filename, Collection<String> bannedNames) {
	filename = Util.canon(filename);
	if (bannedNames.contains(filename)) {
		OurDialog.alert("The filename \"" + filename + "\"\nis already open in another tab.");
		return false;
	}
	try {
		Util.writeAll(filename, pane.getText());
	} catch (Throwable e) {
		OurDialog.alert("Error writing to the file \"" + filename + "\"");
		return false;
	}
	this.filename = Util.canon(filename); // a new file's canonical name may
											// change
	modified = false;
	isFile = true;
	listeners.fire(this, Event.STATUS_CHANGE);
	return true;
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:24,代碼來源:OurSyntaxWidget.java

示例6: do_action

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
public Object do_action(Object sender, Event e) {
   final OurTabbedSyntaxWidget me = OurTabbedSyntaxWidget.this;
   if (sender instanceof OurSyntaxWidget) switch(e) {
      case FOCUSED:        listeners.fire(me, e); break;
      case CARET_MOVED:    listeners.fire(me, Event.STATUS_CHANGE); break;
      case CTRL_PAGE_UP:   prev(); break;
      case CTRL_PAGE_DOWN: next(); break;
      case STATUS_CHANGE:
         clearShade();
         OurSyntaxWidget t = (OurSyntaxWidget)sender;
         String n = t.getFilename();
         t.obj1.setToolTipText(n);
         int i = n.lastIndexOf('/'); if (i >= 0) n = n.substring(i + 1);
         i = n.lastIndexOf('\\');    if (i >= 0) n = n.substring(i + 1);
         i = n.lastIndexOf('.');     if (i >= 0) n = n.substring(0, i);
         if (n.length() > 14) { n = n.substring(0, 14) + "..."; }
         if (t.obj1 instanceof JLabel) { ((JLabel)(t.obj1)).setText("  " + n + (t.modified() ? " *  " : "  ")); }
         listeners.fire(me, Event.STATUS_CHANGE);
         break;
   }
   return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:23,代碼來源:OurTabbedSyntaxWidget.java

示例7: shade

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/** Highlights the text editor, based on the location information in the set of Pos objects. */
public void shade(Iterable<Pos> set, Color color, boolean clearOldHighlightsFirst) {
   if (clearOldHighlightsFirst) clearShade();
   OurSyntaxWidget text = null;
   int c = 0, d;
   for(Pos p: set) if (p!=null && p.filename.length()>0 && p.y>0 && p.x>0 && newtab(p.filename)) {
      text = get();
      c = text.getLineStartOffset(p.y-1) + p.x - 1;
      d = text.getLineStartOffset(p.y2-1) + p.x2 - 1;
      text.shade(color, c, d+1);
   }
   if (text!=null) { text.moveCaret(0, 0); text.moveCaret(c, c); } // Move to 0 ensures we'll scroll to the highlighted section
   get().requestFocusInWindow();
   adjustLabelColor();
   listeners.fire(this, Event.STATUS_CHANGE);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:17,代碼來源:OurTabbedSyntaxWidget.java

示例8: discard

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/**
 * Discard all; if askUser is true, we'll ask the user whether to save it or
 * not if the modified==true.
 * 
 * @return true if this text buffer is now a fresh empty text buffer
 */
boolean discard(boolean askUser, Collection<String> bannedNames) {
	char ans = (!modified || !askUser) ? 'd' : OurDialog.askSaveDiscardCancel("The file \"" + filename + "\"");
	if (ans == 'c' || (ans == 's' && save(false, bannedNames) == false))
		return false;
	for (int i = 1;; i++)
		if (!bannedNames.contains(filename = Util.canon("Untitled " + i + ".als")))
			break;
	pane.setText("");
	clearUndo();
	modified = false;
	isFile = false;
	listeners.fire(this, Event.STATUS_CHANGE);
	return true;
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:21,代碼來源:OurSyntaxWidget.java

示例9: select

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/** Switch to the i-th tab (Note: if successful, it will always send STATUS_CHANGE to the registered listeners. */
private void select(int i) {
   if (i < 0 || i >= tabs.size()) return; else { me=i; component.revalidate(); adjustLabelColor(); component.removeAll(); }
   if (tabs.size() > 1) component.add(tabBarScroller, BorderLayout.NORTH);
   tabs.get(me).addTo(component, BorderLayout.CENTER);
   component.repaint();
   tabs.get(me).requestFocusInWindow();
   tabBar.scrollRectToVisible(new Rectangle(0,0,0,0)); // Forces recalculation
   tabBar.scrollRectToVisible(new Rectangle(tabs.get(me).obj2.getX(), 0, tabs.get(me).obj2.getWidth()+200, 1));
   listeners.fire(this, Event.STATUS_CHANGE);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:12,代碼來源:OurTabbedSyntaxWidget.java

示例10: discard

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/** Discard all; if askUser is true, we'll ask the user whether to save it or not if the modified==true.
 * @return true if this text buffer is now a fresh empty text buffer
 */
boolean discard(boolean askUser, Collection<String> bannedNames) {
   char ans = (!modified || !askUser) ? 'd' : OurDialog.askSaveDiscardCancel("The file \"" + filename + "\"");
   if (ans=='c' || (ans=='s' && save(false, bannedNames)==false)) return false;
   for(int i=1; ;i++) if (!bannedNames.contains(filename = Util.canon("Untitled " + i + ".als"))) break;
   pane.setText(""); clearUndo(); modified=false; isFile=false; listeners.fire(this, Event.STATUS_CHANGE);
   return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:11,代碼來源:OurSyntaxWidget.java

示例11: load

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/** Discard current content then read the given file; return true if the entire operation succeeds. */
boolean load(String filename) {
   String x;
   try {
      x = Util.readAll(filename);
   } catch(Throwable ex) { OurDialog.alert("Error reading the file \"" + filename + "\""); return false; }
   pane.setText(x); moveCaret(0,0); clearUndo(); modified=false; isFile=true; this.filename=filename;
   listeners.fire(this, Event.STATUS_CHANGE);
   return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:11,代碼來源:OurSyntaxWidget.java

示例12: reload

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/** Discard (after confirming with the user) current content then reread from disk file. */
void reload() {
   if (!isFile) return; // "untitled" text buffer does not have a on-disk file to refresh from
   if (modified && !OurDialog.yesno("You have unsaved changes to \"" + filename + "\"\nAre you sure you wish to discard "
         + "your changes and reload it from disk?", "Discard your changes", "Cancel this operation")) return;
   String t;
   try { t=Util.readAll(filename); } catch(Throwable ex) { OurDialog.alert("Cannot read \""+filename+"\""); return; }
   if (modified==false && t.equals(pane.getText())) return; // no text change nor status change
   int c=pane.getCaretPosition();  pane.setText(t);  moveCaret(c,c);  modified=false;  listeners.fire(this, Event.STATUS_CHANGE);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:11,代碼來源:OurSyntaxWidget.java

示例13: saveAs

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/** Save the current tab content to the file system, and return true if successful. */
boolean saveAs(String filename, Collection<String> bannedNames) {
   filename = Util.canon(filename);
   if (bannedNames.contains(filename)) {
      OurDialog.alert("The filename \""+filename+"\"\nis already open in another tab.");
      return false;
   }
   try { Util.writeAll(filename, pane.getText()); }
   catch (Throwable e) { OurDialog.alert("Error writing to the file \""+filename+"\""); return false; }
   this.filename = Util.canon(filename); // a new file's canonical name may change
   modified=false; isFile=true; listeners.fire(this, Event.STATUS_CHANGE);  return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:13,代碼來源:OurSyntaxWidget.java

示例14: do_action

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
public Object do_action(Object sender, Event e) {
	final OurTabbedSyntaxWidget me = OurTabbedSyntaxWidget.this;
	if (sender instanceof OurSyntaxWidget)
		switch (e) {
			case FOCUSED :
				listeners.fire(me, e);
				break;
			case CARET_MOVED :
				listeners.fire(me,
						Event.STATUS_CHANGE);
				break;
			case CTRL_PAGE_UP :
				prev();
				break;
			case CTRL_PAGE_DOWN :
				next();
				break;
			case STATUS_CHANGE :
				clearShade();
				OurSyntaxWidget t = (OurSyntaxWidget) sender;
				String n = t.getFilename();
				t.obj1.setToolTipText(n);
				int i = n.lastIndexOf('/');
				if (i >= 0)
					n = n.substring(i + 1);
				i = n.lastIndexOf('\\');
				if (i >= 0)
					n = n.substring(i + 1);
				i = n.lastIndexOf('.');
				if (i >= 0)
					n = n.substring(0, i);
				if (n.length() > 14) {
					n = n.substring(0, 14) + "...";
				}
				if (t.obj1 instanceof JLabel) {
					((JLabel) (t.obj1)).setText("  "
							+ n
							+ (t.modified() ? " *  "
									: "  "));
				}
				listeners.fire(me,
						Event.STATUS_CHANGE);
				break;
		}
	return true;
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:47,代碼來源:OurTabbedSyntaxWidget.java

示例15: fire

import edu.mit.csail.sdg.alloy4.Listener.Event; //導入依賴的package包/類
/** Send the following zero-argument event to every listener. */
public void fire(Object sender, Event event) {
	for (Listener x : listeners)
		x.do_action(sender, event);
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:6,代碼來源:Listeners.java


注:本文中的edu.mit.csail.sdg.alloy4.Listener.Event類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。