Java Code Examples for org.eclipse.swt.SWT#CLOSE

The following examples show how to use org.eclipse.swt.SWT#CLOSE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TipOfTheDay.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Build the shell
 *
 * @param parent parent shell
 */
private void buildShell(final Shell parent) {
	shell = new Shell(parent, SWT.SYSTEM_MODAL | SWT.TITLE | SWT.BORDER | SWT.CLOSE | SWT.RESIZE);
	shell.setText(ResourceManager.getLabel(ResourceManager.TIP_OF_THE_DAY));
	shell.setLayout(new GridLayout(style == TipStyle.HEADER ? 1 : 2, false));

	shell.addListener(SWT.Traverse, event -> {
		switch (event.detail) {
			case SWT.TRAVERSE_ESCAPE:
				shell.dispose();
				event.detail = SWT.TRAVERSE_NONE;
				event.doit = false;
				break;
		}
	});
}
 
Example 2
Source File: OlapInputAboutDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param shell
 *          the shell.
 */
public OlapInputAboutDialog( final Shell shell ) {
  this.dialog = new Shell( shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET );
  GridLayout gridLayout = new GridLayout();
  gridLayout.numColumns = 2;

  this.dialog.setLayout( gridLayout );
  this.dialog.setText( BaseMessages.getString( PKG, "OlapInputDialog.About.Shell.Title" ) );
  this.dialog.setImage( shell.getImage() );

  this.buildIconCell();
  this.buildPluginInfoCell();
  this.buildOkButton();

  this.dialog.pack();
  Rectangle shellBounds = shell.getBounds();
  Point dialogSize = this.dialog.getSize();

  this.dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y
    + ( shellBounds.height - dialogSize.y ) / 2 );
}
 
Example 3
Source File: SapInputAboutDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param shell
 *          the shell.
 */
public SapInputAboutDialog( final Shell shell ) {
  this.dialog = new Shell( shell, SWT.BORDER | SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.SHEET );
  GridLayout gridLayout = new GridLayout();
  gridLayout.numColumns = 2;

  this.dialog.setLayout( gridLayout );
  this.dialog.setText( BaseMessages.getString( PKG, "SapInputDialog.About.Shell.Title" ) );
  this.dialog.setImage( shell.getImage() );

  this.buildIconCell();
  this.buildPluginInfoCell();
  this.buildOkButton();

  this.dialog.pack();
  Rectangle shellBounds = shell.getBounds();
  Point dialogSize = this.dialog.getSize();

  this.dialog.setLocation( shellBounds.x + ( shellBounds.width - dialogSize.x ) / 2, shellBounds.y
    + ( shellBounds.height - dialogSize.y ) / 2 );
}
 
Example 4
Source File: BeamHelper.java    From kettle-beam with Apache License 2.0 5 votes vote down vote up
public void showMessage( String title, String message ) {

    MessageBox messageBox = new MessageBox( spoon.getShell(), SWT.ICON_INFORMATION | SWT.CLOSE );
    messageBox.setText( title );
    messageBox.setMessage( message );
    messageBox.open();
  }
 
Example 5
Source File: DataQualityShell.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private DataQualityShell(Shell parent, DQSystem system, String dqEntry) {
	super(parent, SWT.TITLE | SWT.RESIZE | SWT.CLOSE | SWT.APPLICATION_MODAL);
	this.system = system;
	this.dqEntry = dqEntry;
	setLayout(new FillLayout(SWT.HORIZONTAL));
	setText(M.PedigreeMatrix);
	setSize(830, 750);
	UI.center(parent, this);
}
 
Example 6
Source File: StandardDialogs.java    From jbt with Apache License 2.0 5 votes vote down vote up
public static void exceptionDialog(String title, String errorMessage, List<Exception> exceptions) {
	String exceptionMessage = new String();
	for (Exception currentException : exceptions) {
		exceptionMessage += "** Exception **\n\n"
				+ Utilities.stackTraceToString(currentException) + "\n\n";
	}
	DetailsDialog dialog=new DetailsDialog(title, errorMessage, exceptionMessage, DetailsDialog.ERROR, null,
			SWT.APPLICATION_MODAL | SWT.RESIZE | SWT.MIN | SWT.MAX | SWT.CLOSE);
	
	dialog.setBlockOnOpen(true);
	dialog.open();
}
 
Example 7
Source File: StandardDialogs.java    From jbt with Apache License 2.0 5 votes vote down vote up
public static void exceptionDialog(String title, String errorMessage, Exception e) {
	DetailsDialog dialog = new DetailsDialog(title, errorMessage,
			Utilities.stackTraceToString(e), DetailsDialog.ERROR, null, SWT.APPLICATION_MODAL
					| SWT.RESIZE | SWT.MIN | SWT.MAX | SWT.CLOSE);
	dialog.setBlockOnOpen(true);
	dialog.open();
}
 
Example 8
Source File: JobGraph.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void replayJob() {
  List<JobEntryCopy> selectedEntries = jobMeta.getSelectedEntries();
  if ( selectedEntries.size() != 1 ) {
    MessageBox box = new MessageBox( shell, SWT.ICON_INFORMATION | SWT.CLOSE );
    box.setText( BaseMessages.getString( PKG, "JobGraph.ReplayJob.SelectOneEntryToStartFrom.Title" ) );
    box.setMessage( BaseMessages.getString( PKG, "JobGraph.ReplayJob.SelectOneEntryToStartFrom.Message" ) );
    box.open();
    return;
  }

  JobEntryCopy copy = selectedEntries.get( 0 );

  spoon.executeJob( jobMeta, true, false, null, false, copy.getName(), copy.getNr() );
}
 
Example 9
Source File: GotoLineShell.java    From RepDev with GNU General Public License v3.0 4 votes vote down vote up
private void create(Shell parent, StyledText txt) {
	display = parent.getDisplay();
	
	this.txt = txt;
	
	shell = new Shell( parent, SWT.APPLICATION_MODAL | SWT.CLOSE | SWT.TITLE );
	shell.setText("Goto Line");
	
	FormLayout layout = new FormLayout();
	layout.marginTop = 10;
	layout.marginBottom = 10;
	layout.marginLeft = 10;
	layout.marginRight = 10;
	layout.spacing = 5;
	
	shell.setLayout(layout);
			
	final Label gotoLabel = new Label( shell, SWT.None );
	gotoLabel.setText("Enter Line Number (1..." + txt.getLineCount() + ")");
	
	final Text gotoText = new Text(shell, SWT.BORDER | SWT.SINGLE );
	
	final Button go = new Button(shell, SWT.PUSH );
	go.setText("Goto Line");
	
	FormData data = new FormData();
	data.top = new FormAttachment(0);
	data.left = new FormAttachment(0);
	gotoLabel.setLayoutData(data);
	
	data = new FormData();
	data.top = new FormAttachment(gotoLabel);
	data.left = new FormAttachment(0);
	data.right = new FormAttachment(100);
	gotoText.setLayoutData(data);
	
	data = new FormData();
	data.top = new FormAttachment(gotoText);
	data.left = new FormAttachment(0);
	data.right = new FormAttachment(100);
	data.bottom = new FormAttachment(100);
	go.setLayoutData(data);
	
	go.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent e) {
			try {
				setLine(Integer.parseInt(gotoText.getText()));
				shell.dispose();
			} catch (Exception ex) {
				// System.err.println(ex.getMessage());
			}
		}			
	});
	
	shell.setDefaultButton(go);
	shell.pack();
	shell.open();
			
}
 
Example 10
Source File: CaptureDialog.java    From logbook with MIT License 4 votes vote down vote up
/**
 * Create the dialog.
 * @param parent
 */
public CaptureDialog(Shell parent) {
    super(parent, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.RESIZE);
    this.setText("キャプチャ");
}
 
Example 11
Source File: TabItem.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected CTabItem createTabItem( TabSet tabset ) {
  return new CTabItem( tabset.getSwtTabset(), SWT.CLOSE );
}
 
Example 12
Source File: EditorTextWindow.java    From ldparteditor with MIT License 4 votes vote down vote up
/**
 * Run a fresh instance of this window
 */
public void run(DatFile fileToOpen, boolean closeASAP) {
    if (!isSeperateWindow()) {
        return;
    }
    Project.getOpenTextWindows().add(this);
    // Load the window state data
    this.editorTextWindowState = WorkbenchManager.getEditorTextWindowState();
    // Creating the window to get the shell
    this.create();
    final Shell sh = this.getShell();
    sh.setText(Version.getApplicationName() + " " + Version.getVersion()); //$NON-NLS-1$
    sh.setImage(ResourceManager.getImage("imgDuke2.png")); //$NON-NLS-1$
    sh.setMinimumSize(640, 480);
    sh.setBounds(this.editorTextWindowState.getWindowState().getSizeAndPosition());
    if (this.editorTextWindowState.getWindowState().isCentered()) {
        ShellHelper.centerShellOnPrimaryScreen(sh);
    }
    // Maximize has to be called asynchronously
    sh.getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {
            try {
                if (!sh.isDisposed()) {
                    sh.setMaximized(editorTextWindowState.getWindowState().isMaximized());
                    sh.forceActive();
                }
            } catch (SWTException consumed) {}
        }
    });
    // The window reference has to be added to the tab folder
    tabFolder[0].setWindow(editorTextWindow);
    // and the tab for the file has to be created.
    {
        CompositeTab tbtmnewItem = new CompositeTab(tabFolder[0], SWT.CLOSE);
        tbtmnewItem.setFolderAndWindow(tabFolder[0], editorTextWindow);
        tbtmnewItem.getState().setFileNameObj(fileToOpen);
        tbtmnewItem.parseForErrorAndHints();
        tabFolder[0].setSelection(tbtmnewItem);
    }

    // MARK All final listeners will be configured here..
    registerEvents();

    this.open();
    if (closeASAP) {
        closeTabWithDatfile(Project.getFileToEdit());
    }
}
 
Example 13
Source File: NewTmxFileDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int getShellStyle() {
	return super.getShellStyle() | SWT.TITLE | SWT.CLOSE;
}
 
Example 14
Source File: VersionDialog.java    From logbook with MIT License 4 votes vote down vote up
/**
 * Create the dialog.
 * @param parent
 */
public VersionDialog(Shell parent) {
    super(parent, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.RESIZE);
    this.setText("バージョン情報");
}
 
Example 15
Source File: MainShell.java    From RepDev with GNU General Public License v3.0 4 votes vote down vote up
public Object openFile(final SymitarFile file) {
	boolean found = false;
	Composite editor;
	Object loc;

	if (file.isLocal())
		loc = file.getDir();
	else
		loc = file.getSym();

	for (CTabItem c : mainfolder.getItems()) {
		if (c.getData("file") != null && c.getData("file").equals(file) && c.getData("loc") != null && c.getData("loc").equals(loc)) {
			setMainFolderSelection(c);
			found = true;
			return c.getControl();
		}
	}

	if (!found) {
		CTabItem item = new CTabItem(mainfolder, SWT.CLOSE); 
		item.setText(file.getName());
		// item.setToolTipText(file.getName()); // only use this if we are shrinking tabs
		item.setImage(getFileImage(file));
		item.setData("file", file);
		item.setData("loc", loc);

		if (file.getType() == FileType.REPORT)
			editor = new ReportComposite(mainfolder, item, file);
		else {
			editor = new EditorComposite(mainfolder, item, file /*
			 * ,save,
			 * install,
			 * print,
			 * run
			 */);
			//EditorCompositeList.add((EditorComposite)editor);
		}

		// If anything goes wrong creating the Editor, we want to fail here
		// It will dispose of the item to indicate this fault.
		if (item.isDisposed()) {
			MessageBox dialog = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
			dialog.setMessage("There has been an error loading this file, the filename is probably too long");
			dialog.setText("Error");
			dialog.open();

			return null;
		}

		mainfolder.setSelection(item);
		item.setControl(editor);
		setMainFolderSelection(item);
		mainfolder.notifyListeners(SWT.Selection, new Event());
		


		//When we are closing, we must dispose the control in the CTabItem, otherwise we leak swt objects
		item.addDisposeListener(new DisposeListener(){
			public void widgetDisposed(DisposeEvent e) {
				if(((CTabItem)e.widget).getControl() != null)
					((CTabItem)e.widget).getControl().dispose();
			}
		});

		if (file.getType() != FileType.REPGEN || file.isLocal())
			install.setEnabled(false);
		else
			install.setEnabled(true);

		if (file.getType() != FileType.REPGEN || file.isLocal())
			run.setEnabled(false);
		else
			run.setEnabled(true);

		savetb.setEnabled(true);

		if ((file.getType() == FileType.REPGEN)||(file.getType() == FileType.LETTER)||(file.getType() == FileType.HELP))
			hltoggle.setEnabled(true);

		if (mainfolder.getSelection().getControl() instanceof EditorComposite){
			if(((EditorComposite)mainfolder.getSelection().getControl()).getHighlight()){
				hltoggle.setImage(RepDevMain.smallHighlight);
			}else{
				hltoggle.setImage(RepDevMain.smallHighlightGrey);
			}
		}
		// Attach find/replace shell here as well (in addition to folder
		// listener)
		findReplaceShell.attach(((EditorComposite) mainfolder.getSelection().getControl()).getStyledText(), true);

		if (!Config.getRecentFiles().contains(file))
			Config.getRecentFiles().add(0, file);

		if (Config.getRecentFiles().size() > MAX_RECENTS)
			Config.getRecentFiles().remove(Config.getRecentFiles().size() - 1);
		return editor;
	}

	return null;
}
 
Example 16
Source File: ChipsSnippet.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private static void createCloseImageChipsArea() {
	final Label lbl = new Label(shell, SWT.CENTER);
	lbl.setText("Close & Images (Nebula Devs)");
	lbl.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	final Composite cmp = new Composite(shell, SWT.NONE);
	cmp.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
	cmp.setLayout(new GridLayout(5, false));
	cmp.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));

	final Color bgColor = SWTGraphicUtil.getColorSafely(224, 224, 244);

	final Chips chip1 = new Chips(cmp, SWT.CLOSE);
	chip1.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip1.setChipsBackground(bgColor);
	chip1.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	chip1.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip1.setImage(loadImage("dirk.png"));
	chip1.setText("Dirk");
	chip1.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));

	final Chips chip2 = new Chips(cmp, SWT.CLOSE);
	chip2.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip2.setChipsBackground(bgColor);
	chip2.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	chip2.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip2.setImage(loadImage("donald.png"));
	chip2.setText("Donald");
	chip2.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));

	final Chips chip3 = new Chips(cmp, SWT.CLOSE);
	chip3.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip3.setChipsBackground(bgColor);
	chip3.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	chip3.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip3.setImage(loadImage("johannes.png"));
	chip3.setText("Johannes");
	chip3.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));

	final Chips chip4 = new Chips(cmp, SWT.CLOSE);
	chip4.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip4.setChipsBackground(bgColor);
	chip4.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	chip4.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip4.setImage(loadImage("laurent.png"));
	chip4.setText("Laurent");
	chip4.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));

	final Chips chip5 = new Chips(cmp, SWT.CLOSE);
	chip5.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip5.setChipsBackground(bgColor);
	chip5.setHoverForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	chip5.setHoverBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
	chip5.setImage(loadImage("wim.png"));
	chip5.setText("Wim");
	chip5.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));

	final CloseListener closeListener = event -> {
		final Chips chip = (Chips) event.widget;
		System.out.println("Closed on " + chip.getText());
		chip.dispose();
		cmp.layout(true);
	};

	chip1.addCloseListener(closeListener);
	chip2.addCloseListener(closeListener);
	chip3.addCloseListener(closeListener);
	chip4.addCloseListener(closeListener);

}
 
Example 17
Source File: CompositeTab.java    From ldparteditor with MIT License 4 votes vote down vote up
/**
 * Moves the tab to a new index position within another window
 *
 * @param folder
 *            the new tab folder
 * @param index
 *            the new index
 * @return the new tab instance
 */
public CompositeTab moveToFolder(CompositeTabFolder folder, int index) {

    if (this.state.getTab().getParent().equals(folder)) {
        int index2 = 0;
        for (CTabItem t : folder.getItems()) {
            if (((CompositeTab) t).getState().getFileNameObj().equals(state.getFileNameObj()))
                break;
            index2++;
        }
        if (index == index2)
            return this.state.getTab();
    }
    if (index != 0) {
        if (!this.state.getTab().getParent().equals(folder))
            index--;
    }
    final CompositeTab ct = new CompositeTab(folder, SWT.CLOSE, index);
    ct.setText(this.state.getTab().getText());
    ct.getControl().dispose();
    ct.canvas_lineNumberArea[0] = this.canvas_lineNumberArea[0];
    ct.compositeText[0] = this.compositeText[0];
    ct.compositeContainer[0] = this.compositeContainer[0];
    ct.sashForm[0] = this.sashForm[0];
    ct.tabFolder_partInformation[0] = this.tabFolder_partInformation[0];
    ct.tree_Problems[0] = this.tree_Problems[0];
    ct.treeItem_Hints[0] = this.treeItem_Hints[0];
    ct.treeItem_Warnings[0] = this.treeItem_Warnings[0];
    ct.treeItem_Errors[0] = this.treeItem_Errors[0];
    ct.treeItem_Duplicates[0] = this.treeItem_Duplicates[0];
    ct.btn_Inspect[0] = this.btn_Inspect[0];
    ct.btn_InspectSame[0] = this.btn_InspectSame[0];
    ct.btn_QuickFix[0] = this.btn_QuickFix[0];
    ct.btn_QuickFixSame[0] = this.btn_QuickFixSame[0];
    ct.lbl_ProblemCount[0] = this.lbl_ProblemCount[0];
    try {
        ct.setControl(this.state.getTab().getControl());
    } catch (IllegalArgumentException e) {
        this.state.getTab().getControl().setParent(folder);
        ct.setControl(this.state.getTab().getControl());
    }
    this.state.getTab().dispose();
    ct.restoreState(state);
    ct.setFolderAndWindow(folder, folder.getWindow());
    return ct;
}
 
Example 18
Source File: Chips.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private static int checkStyle(final int style) {
	final int mask = SWT.CLOSE | SWT.CHECK | SWT.PUSH;
	int newStyle = style & mask;
	newStyle |= SWT.DOUBLE_BUFFERED;
	return newStyle;
}
 
Example 19
Source File: InspectTransactionDialog.java    From offspring with MIT License 4 votes vote down vote up
@Override
protected void setShellStyle(int newShellStyle) {
  super.setShellStyle(SWT.CLOSE | SWT.MODELESS | SWT.BORDER | SWT.TITLE
      | SWT.RESIZE);
  setBlockOnOpen(false);
}
 
Example 20
Source File: CreatePacFileDialog.java    From logbook with MIT License 2 votes vote down vote up
/**
 * Create the dialog.
 * @param parent
 */
public CreatePacFileDialog(Shell parent) {
    super(parent, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.RESIZE);
}