Java Code Examples for org.eclipse.swt.custom.CTabItem#dispose()

The following examples show how to use org.eclipse.swt.custom.CTabItem#dispose() . 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: SourceMapView.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Called when new mapping are to be loaded, e.g. when active editor has changed. This method must be called before
 * all resolve methods.
 */
private void reset() {
	textGen.setText("");
	textMapFile.setText("");
	textMappings.setText("");
	textMessages.setText("");
	for (StyledText t : textOrgs.values()) {
		t.dispose();
	}
	CTabItem[] items = tabsOrg.getItems();
	for (CTabItem item : items) {
		item.dispose();
	}
	textOrgs.clear();
	sourceMap = null;
	mappingEntriesByIndex.clear();
	mappingEntriesAsList.clear();
	textMarkers.clear();

}
 
Example 2
Source File: TabbedEntry.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void destroyEntry( boolean userInitiated ) {
	if (Utils.runIfNotSWTThread(()->destroyEntry(userInitiated))) {
		return;
	}

	if (swtItem == null) {
		return;
	}

	// Must make a copy of swtItem because swtItem.dispose will end up in
	// this method again, with swtItem.isDisposed() still false.
	CTabItem item = swtItem;
	swtItem = null;

	super.destroyEntry( userInitiated );

	try {
		if (!item.isDisposed()) {
			item.dispose();
		}
	}catch( SWTException e ){
		// getting internal 'Widget it disposed' here, ignore
	}
}
 
Example 3
Source File: QueryCreator.java    From Rel with Apache License 2.0 6 votes vote down vote up
@Override
public void go(DbTreeItem item, String imageName) {
	RevDatabase database = new RevDatabase(relPanel.getConnection());
	NewItemDialog namer = new NewItemDialog(relPanel.getShell(), "Query" + database.getUniqueNumber());
	if (namer.open() != NewItemDialog.OK)
		return;
	if (database.modelExists(namer.getName())) {
		MessageDialog.openInformation(relPanel.getShell(), "Note", "A query named " + namer.getName() + " already exists.");
		return;
	}
	DbTreeItem newItem = new DbTreeItem(item, namer.getName());
	CTabItem tab = relPanel.getTab(newItem);
	if (tab != null)
		tab.dispose();
	RevTab revtab = new RevTab(relPanel, newItem, Rev.EDITABLE);
	revtab.addModelChangeListener(new ModelChangeListener() {
		public void modelChanged() {
			relPanel.redisplayed();
		}
	});
	relPanel.setTab(revtab, imageName);
}
 
Example 4
Source File: VarEditor.java    From Rel with Apache License 2.0 6 votes vote down vote up
@Override
public void go(DbTreeItem item, String imageName) {
	FilterSorter filterSorter = null;		
	CTabItem tab = relPanel.getTab(item);
	if (tab != null) {
		if (tab instanceof ExpressionResultViewerTab)
			filterSorter = ((ExpressionResultViewerTab)tab).getFilterSorter();
		if (tab instanceof VarEditorTab) {
			relPanel.setTab(tab);
			return;
		} else
			tab.dispose();
	}
	VarEditorTab editor = new VarEditorTab(relPanel, item, filterSorter);
	relPanel.setTab(editor, imageName);
}
 
Example 5
Source File: VarPlayer.java    From Rel with Apache License 2.0 6 votes vote down vote up
@Override
public void go(DbTreeItem item, String imageName) {
	FilterSorter filterSorter = null;
	CTabItem tab = relPanel.getTab(item);
	if (tab != null) {
		if (tab instanceof VarEditorTab)
			filterSorter = ((VarEditorTab)tab).getFilterSorter();
		if (tab instanceof ExpressionResultViewerTab) {
			relPanel.setTab(tab);
			return;
		} else
			tab.dispose();
	}
	ExpressionResultViewerTab viewer = new ExpressionResultViewerTab(relPanel, item, filterSorter);
	relPanel.setTab(viewer, imageName);
}
 
Example 6
Source File: UserDefinedJavaClassDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void modifyCTabItem( TreeItem tItem, TabActions iModType, String strOption ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        CTabItem dItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;

      case RENAME_ITEM:
        CTabItem rItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( rItem != null ) {
          rItem.setText( strOption );
          input.setChanged();
          if ( rItem.getImage().equals( imageActiveScript ) ) {
            strActiveScript = strOption;
          }
        }
        break;
      case SET_ACTIVE_ITEM:
        CTabItem aItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( aItem != null ) {
          input.setChanged();
          strActiveScript = tItem.getText();
          for ( int i = 0; i < folder.getItemCount(); i++ ) {
            if ( folder.getItem( i ).equals( aItem ) ) {
              aItem.setImage( imageActiveScript );
            } else {
              folder.getItem( i ).setImage( imageInactiveScript );
            }
          }
        }
        break;
      default:
        break;
    }

  }
 
Example 7
Source File: ComponentTitledFolder.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the given item invisible
 * @param item
 */
private boolean setInvisible(String text) {
    for (CTabItem item : folder.getItems()){
        label: if (item.getText().equals(text)) {
            for (TitledFolderEntry entry : this.entries) {
                if (entry.text.equals(text) && !entry.hideable) {
                    break label;
                }
            }
            item.dispose();
            return true;
        }
    }
    return false;
}
 
Example 8
Source File: EditorTextWindow.java    From ldparteditor with MIT License 5 votes vote down vote up
public void closeTabWithDatfile(DatFile e) {
    CTabItem[] items =  tabFolder[0].getItems().clone();
    for (CTabItem item : items) {
        CompositeTab cTab = (CompositeTab) item;
        if (cTab.getState().getFileNameObj().equals(e)) {
            item.dispose();
        }
    }
    if (isSeperateWindow() && tabFolder[0].getItemCount() == 0) {
        Project.getOpenTextWindows().remove(this);
        close();
    }
}
 
Example 9
Source File: ChatRoomsComposite.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
private boolean closeChatTab(IChat chat) {
  CTabItem tab = getChatTab(chat);
  if (tab != null && !tab.isDisposed()) {
    tab.dispose();

    updateExplanation();
    return true;
  }

  return false;
}
 
Example 10
Source File: VarViewPlayer.java    From Rel with Apache License 2.0 5 votes vote down vote up
@Override
public void go(DbTreeItem item, String imageName) {
	CTabItem tab = relPanel.getTab(item);
	if (tab != null) {
		if (tab instanceof ExpressionResultViewerTab) {
			relPanel.setTab(tab);
			return;
		} else
			tab.dispose();
	}
	ExpressionResultViewerTab viewer = new ExpressionResultViewerTab(relPanel, item, null);
	relPanel.setTab(viewer, imageName);
}
 
Example 11
Source File: VarDesigner.java    From Rel with Apache License 2.0 5 votes vote down vote up
@Override
public void go(DbTreeItem item, String imageName) {
	CTabItem tab = relPanel.getTab(item);
	if (tab != null) {
		if (tab instanceof VarRealDesignerTab) {
			relPanel.setTab(tab);
			return;
		} else
			tab.dispose();
	}
	VarRealDesignerTab varDesignTab = new VarRealDesignerTab(relPanel, item);
	relPanel.setTab(varDesignTab, imageName);
}
 
Example 12
Source File: VarCreator.java    From Rel with Apache License 2.0 5 votes vote down vote up
@Override
public void go(DbTreeItem item, String imageName) {
	RevDatabase database = new RevDatabase(relPanel.getConnection());
	VarTypeDialog namer = new VarTypeDialog(database, relPanel.getShell());
	String typeString = namer.open();
	if (typeString == null)
		return;
	if (typeString.equalsIgnoreCase("REAL")) {
		NewItemDialog varNameDialog = new NewItemDialog(relPanel.getShell(), "Variable" + database.getUniqueNumber());
		if (varNameDialog.open() != NewItemDialog.OK)
			return;
		String varname = varNameDialog.getName();
		if (database.relvarExists(varname)) {
			MessageDialog.openInformation(relPanel.getShell(), "Note", "A variable named " + varname + " already exists.");
			return;
		}
		ExecuteResult result = relPanel.getConnection().execute("VAR " + varname + " REAL RELATION {} KEY {};");
		if (result.failed()) {
			MessageDialog.openError(relPanel.getShell(), "Error", "Unable to create variable " + varname + ": " + result.getErrorMessage());
			return;
		}
		relPanel.redisplayed();
		DbTreeItem newItem = new DbTreeItem(item, varname);
		CTabItem tab = relPanel.getTab(newItem);
		if (tab != null)
			tab.dispose();
		VarRealDesignerTab varDesignTab = new VarRealDesignerTab(relPanel, newItem);
		relPanel.setTab(varDesignTab, imageName);
	} else {
		VarExternalDefinitionDialog veDialog = new VarExternalDefinitionDialog(database, relPanel.getShell(), typeString, "Variable" + database.getUniqueNumber());
		if (veDialog.create())
			relPanel.redisplayed();
	}
}
 
Example 13
Source File: MainShell.java    From RepDev with GNU General Public License v3.0 5 votes vote down vote up
private int removeFile(TreeItem cur, int lastResult) {
	if (!(cur.getData() instanceof SymitarFile))
		return 0;

	SymitarFile file = (SymitarFile) cur.getData();
	Project proj = (Project) cur.getParentItem().getData();
	int result = lastResult;

	if ((lastResult & RemFileShell.REPEAT) == 0)
		result = RemFileShell.confirm(display, shell, proj, file);

	if ((result & RemFileShell.OK) > 0 && (result & RemFileShell.DELETE) == 0) {
		proj.removeFile(file, false);
		cur.dispose();
	} else if ((result & RemFileShell.OK) > 0 && (result & RemFileShell.DELETE) > 0) {
		proj.removeFile(file, true);
		cur.dispose();
	}

	if (!proj.isLocal())
		ProjectManager.saveProjects(proj.getSym());
	else
		ProjectManager.saveProjects(proj.getDir());

	tree.notifyListeners(SWT.Selection, null);
	for (CTabItem c : mainfolder.getItems()) {
		if (c.getData("file") != null && c.getData("file").equals(file)) {
			c.dispose();
		}
	}
	return result;
}
 
Example 14
Source File: ScriptDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void modifyCTabItem( TreeItem tItem, int iModType, String strOption ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        CTabItem dItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;

      case RENAME_ITEM:
        CTabItem rItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( rItem != null ) {
          rItem.setText( strOption );
          input.setChanged();
          if ( rItem.getImage().equals( imageActiveScript ) ) {
            strActiveScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveStartScript ) ) {
            strActiveStartScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveEndScript ) ) {
            strActiveEndScript = strOption;
          }
        }
        break;
      case SET_ACTIVE_ITEM:
        CTabItem aItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( aItem != null ) {
          input.setChanged();
          strActiveScript = tItem.getText();
          for ( int i = 0; i < folder.getItemCount(); i++ ) {
            if ( folder.getItem( i ).equals( aItem ) ) {
              aItem.setImage( imageActiveScript );
            } else {
              folder.getItem( i ).setImage( imageInactiveScript );
            }
          }
        }
        break;
      default:
        break;
    }

  }
 
Example 15
Source File: ScriptDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void modifyCTabItem( TreeItem tItem, int iModType, String strOption ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        CTabItem dItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;

      case RENAME_ITEM:
        CTabItem rItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( rItem != null ) {
          rItem.setText( strOption );
          input.setChanged();
          if ( rItem.getImage().equals( imageActiveScript ) ) {
            strActiveScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveStartScript ) ) {
            strActiveStartScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveEndScript ) ) {
            strActiveEndScript = strOption;
          }
        }
        break;
      case SET_ACTIVE_ITEM:
        CTabItem aItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( aItem != null ) {
          input.setChanged();
          strActiveScript = tItem.getText();
          for ( int i = 0; i < folder.getItemCount(); i++ ) {
            if ( folder.getItem( i ).equals( aItem ) ) {
              aItem.setImage( imageActiveScript );
            } else {
              folder.getItem( i ).setImage( imageInactiveScript );
            }
          }
        }
        break;
      default:
        break;
    }

  }
 
Example 16
Source File: MainShell.java    From RepDev with GNU General Public License v3.0 4 votes vote down vote up
protected void compare() {
	if (tree.getSelectionCount() != 2)
		return;

	if (!(tree.getSelection()[0].getData() instanceof SymitarFile))
		return;

	if (!(tree.getSelection()[1].getData() instanceof SymitarFile))
		return;

	Color bgcolor = new Color(Display.getCurrent(),200,200,200);


	//This code gets the correct color to highlight the lines of the compare shell.
	//The only drawback is that it is a bit on the slow side (usually takes about 1 second).
	//In my opinion it is fine to take this bit of time, because the compare shell looks
	//hideous with a custom style without this code. Hopefully we can find a faster way to do
	//this, but for the time being it should work.
	EditorComposite temp = (EditorComposite)openFile((SymitarFile)tree.getSelection()[1].getData());
	for (CTabItem tab : mainfolder.getItems()){
		if (tab.getControl() != null && tab.getControl() instanceof EditorComposite){
			bgcolor =((EditorComposite)mainfolder.getSelection().getControl()).getLineColor();
		}
		if (tab.getControl() != null && tab.getControl() instanceof EditorComposite && tab.getControl() == temp){
			tab.dispose();
		}
	}
	//TODO:Rewrite the above section so that it runs faster, or determines the color in another way


	CTabItem item = new CTabItem(mainfolder, SWT.CLOSE);

	item.setText("Compare Text BETA");
	item.setImage(RepDevMain.smallCompareImage);
	// item.setImage(getFileImage(file));
	// item.setData("file", file);
	// item.setData("loc", loc);

	item.setControl(new CompareComposite(mainfolder, item, (SymitarFile) tree.getSelection()[0].getData(), (SymitarFile) tree.getSelection()[1].getData(), bgcolor));

	item.addDisposeListener(new DisposeListener(){

		public void widgetDisposed(DisposeEvent e) {
			if(((CTabItem)e.widget).getControl() != null)
				((CTabItem)e.widget).getControl().dispose();
		}

	});
	setMainFolderSelection(item);
}
 
Example 17
Source File: ScriptValuesModDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void modifyCTabItem( TreeItem tItem, int iModType, String strOption ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        CTabItem dItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;

      case RENAME_ITEM:
        CTabItem rItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( rItem != null ) {
          rItem.setText( strOption );
          input.setChanged();
          if ( rItem.getImage().equals( imageActiveScript ) ) {
            strActiveScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveStartScript ) ) {
            strActiveStartScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveEndScript ) ) {
            strActiveEndScript = strOption;
          }
        }
        break;
      case SET_ACTIVE_ITEM:
        CTabItem aItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( aItem != null ) {
          input.setChanged();
          strActiveScript = tItem.getText();
          for ( int i = 0; i < folder.getItemCount(); i++ ) {
            if ( folder.getItem( i ).equals( aItem ) ) {
              aItem.setImage( imageActiveScript );
            } else {
              folder.getItem( i ).setImage( imageInactiveScript );
            }
          }
        }
        break;
      default:
        break;
    }

  }
 
Example 18
Source File: EditorTextWindow.java    From ldparteditor with MIT License 4 votes vote down vote up
public void closeAllTabs() {
    CTabItem[] items =  tabFolder[0].getItems().clone();
    for (CTabItem item : items) {
        item.dispose();
    }
}
 
Example 19
Source File: WebServiceDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void removeTabField( CTabItem tab ) {
  if ( tab != null ) {
    tab.dispose();
    tab = null;
  }
}
 
Example 20
Source File: ScriptValuesModDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void modifyCTabItem( TreeItem tItem, int iModType, String strOption ) {

    switch ( iModType ) {
      case DELETE_ITEM:
        CTabItem dItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( dItem != null ) {
          dItem.dispose();
          input.setChanged();
        }
        break;

      case RENAME_ITEM:
        CTabItem rItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( rItem != null ) {
          rItem.setText( strOption );
          input.setChanged();
          if ( rItem.getImage().equals( imageActiveScript ) ) {
            strActiveScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveStartScript ) ) {
            strActiveStartScript = strOption;
          } else if ( rItem.getImage().equals( imageActiveEndScript ) ) {
            strActiveEndScript = strOption;
          }
        }
        break;
      case SET_ACTIVE_ITEM:
        CTabItem aItem = folder.getItem( getCTabPosition( tItem.getText() ) );
        if ( aItem != null ) {
          input.setChanged();
          strActiveScript = tItem.getText();
          for ( int i = 0; i < folder.getItemCount(); i++ ) {
            if ( folder.getItem( i ).equals( aItem ) ) {
              aItem.setImage( imageActiveScript );
            } else {
              folder.getItem( i ).setImage( imageInactiveScript );
            }
          }
        }
        break;
      default:
        break;
    }

  }