Java Code Examples for org.eclipse.swt.widgets.TableItem#dispose()

The following examples show how to use org.eclipse.swt.widgets.TableItem#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: MainShell.java    From RepDev with GNU General Public License v3.0 6 votes vote down vote up
protected void clearErrorAndTaskList(CTabItem item) {
	SymitarFile file = (SymitarFile) (item).getData("file");

	if (file != null) {
		// Remove from error list
		for (TableItem eItem : tblErrors.getItems()) {
			if (((SymitarFile) eItem.getData("file")).equals(file))
				eItem.dispose();
		}

		for (TableItem tItem : tblTasks.getItems()) {
			if (((SymitarFile) tItem.getData("file")).equals(file))
				tItem.dispose();
		}

		for( CTabItem tab: ((CTabFolder)tblErrors.getParent()).getItems() ) {
			if( tab.getText().indexOf("Errors") != -1 ) {
				tab.setText("Errors (" + tblErrors.getItemCount() + ")" );
			} else if( tab.getText().indexOf("Tasks") != -1 ) {
				tab.setText("Tasks (" + tblTasks.getItemCount() + ")" );
			}
		}

	}
}
 
Example 2
Source File: HierarchyWizardPageDate.java    From arx with Apache License 2.0 6 votes vote down vote up
@Override
public void updatePage() {
    
    // Granularities
    for (TableItem item : table.getItems()) {
        item.dispose();
    }
    createItems(table);
    table.select(0);
    
    // Format string
    text.setText(model.getFormat().get((Granularity)table.getItem(0).getData()));
    
    // Top/bottom coding
    editorBottomCoding.update();
    editorTopCoding.update();

    // Timezone
    combo.removeAll();
    createItems(combo);
    combo.select(combo.indexOf(model.getTimeZone().getDisplayName()));
}
 
Example 3
Source File: ViewStatisticsClassificationConfiguration.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the view.
 */
private void updateTable(ARXClassificationConfiguration<?> config){
    
    // Check
    if (this.model == null || config == null) {
        return;
    }
    
    // Clear
    this.root.setRedraw(false);
    for(TableItem item : this.table.getItems()){
        item.dispose();
    }
    
    // Create items based on config
    if (config instanceof ClassificationConfigurationLogisticRegression) {
        createItemsForLogisticRegression((ClassificationConfigurationLogisticRegression) config);
    } else if (config instanceof ClassificationConfigurationNaiveBayes) {
        createItemsForNaiveBayes((ClassificationConfigurationNaiveBayes) config);
    } else if (config instanceof ClassificationConfigurationRandomForest) {
        createItemsForRandomForest((ClassificationConfigurationRandomForest) config);
    }
    
    this.root.setRedraw(true);
    SWTUtil.enable(this.root);
}
 
Example 4
Source File: PTWidgetTable.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @see org.eclipse.nebula.widgets.opal.propertytable.AbstractPTWidget#refillData()
 */
@Override
public void refillData() {
	try {
		table.setRedraw(false);
		for (final TableItem item : table.getItems()) {
			item.dispose();
		}

		if (table.getData() != null) {
			@SuppressWarnings("unchecked")
			final List<ControlEditor> list = (List<ControlEditor>) table.getData();
			for (final ControlEditor c : list) {
				c.dispose();
			}
			list.clear();
			table.setData(null);
		}

		fillData();
	} finally {
		table.setRedraw(true);
		table.redraw();
		table.update();
	}
}
 
Example 5
Source File: ViewStatisticsQuality.java    From arx with Apache License 2.0 6 votes vote down vote up
@Override
protected void doReset() {
    if (this.manager != null) {
        this.manager.stop();
    }
    data = null;
    table.setCurrentPage(0);
    table.refreshPage();
    if (table2 != null) {
        table2.setRedraw(false);
        for (final TableItem i : table2.getItems()) {
            i.dispose();
        }
        table2.setRedraw(true);
    }
    setStatusEmpty();
}
 
Example 6
Source File: ViewStatisticsSummaryTable.java    From arx with Apache License 2.0 5 votes vote down vote up
@Override
protected void doReset() {
    root.setRedraw(false);
    if (this.manager != null) {
        this.manager.stop();
    }
    for (final TableItem i : table.getItems()) {
        i.dispose();
    }
    root.setRedraw(true);
    setStatusEmpty();
}
 
Example 7
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Swap table items.
 *
 * @param itemBelow the item below
 * @param newSelection the new selection
 */
public static void swapTableItems(TableItem itemBelow, int newSelection) {
  Table parent = itemBelow.getParent();
  int i = getIndex(itemBelow);
  TableItem itemAbove = parent.getItems()[i - 1];
  TableItem newItemAbove = new TableItem(parent, SWT.NONE, i - 1);
  copyTableItem(newItemAbove, itemBelow);
  TableItem newItemBelow = new TableItem(parent, SWT.NONE, i);
  copyTableItem(newItemBelow, itemAbove);
  itemAbove.dispose();
  itemBelow.dispose();
  parent.setSelection(newSelection);
}
 
Example 8
Source File: ViewRisksQuasiIdentifiersTable.java    From arx with Apache License 2.0 5 votes vote down vote up
@Override
protected void doReset() {
    if (this.manager != null) {
        this.manager.stop();
    }
    table.setRedraw(false);
    for (final TableItem i : table.getItems()) {
        i.dispose();
    }
    table.setRedraw(true);
    setStatusEmpty();
}
 
Example 9
Source File: ViewRisksOverview.java    From arx with Apache License 2.0 5 votes vote down vote up
@Override
protected void doReset() {
    if (this.manager != null) {
        this.manager.stop();
    }
    table.setRedraw(false);
    for (final TableItem i : table.getItems()) {
        i.dispose();
    }
    table.setRedraw(true);
    setStatusEmpty();
}
 
Example 10
Source File: ComponentRiskProfile.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Resets the table
 */
private void resetTable() {
    if (table == null) {
        return;
    }
    table.setRedraw(false);
    for (final TableItem i : table.getItems()) {
        i.dispose();
    }
    table.clearAll();
    table.setRedraw(true);
}
 
Example 11
Source File: ViewClipboard.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Removes all items.
 */
private void removeAllItems() {
    for (final TableItem i : table.getItems()) {
        i.dispose();
    }
    table.removeAll();
}
 
Example 12
Source File: ViewList.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Resets the view.
 */
@Override
public void reset() {
    super.reset();
    table.setRedraw(false);
    for (final TableItem i : table.getItems()) {
        i.dispose();
    }
    list.clear();
    table.setRedraw(true);
    if (listener != null) {
        table.removeListener(SWT.SetData, listener);
    }
    SWTUtil.disable(table);
}
 
Example 13
Source File: ViewStatisticsEquivalenceClassTable.java    From arx with Apache License 2.0 5 votes vote down vote up
@Override
protected void doReset() {
    if (this.manager != null) {
        this.manager.stop();
    }
    table.setRedraw(false);
    for (final TableItem i : table.getItems()) {
        i.dispose();
    }
    table.setRedraw(true);
    setStatusEmpty();
}
 
Example 14
Source File: ViewStatisticsClassificationConfiguration.java    From arx with Apache License 2.0 5 votes vote down vote up
@Override
public void reset() {
    for(TableItem item : this.table.getItems()){
        item.dispose();
    }
    this.table.removeAll();
    SWTUtil.disable(this.root);
}
 
Example 15
Source File: MainShell.java    From RepDev with GNU General Public License v3.0 5 votes vote down vote up
private boolean confirmClose(CTabItem item) {
	if (item != null && item.getData("modified") != null && ((Boolean) item.getData("modified"))) {
		MessageBox dialog = new MessageBox(shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL);
		dialog.setText("Confirm File Close");

		if (item.getData("loc") instanceof Integer)
			dialog.setMessage("The file '" + item.getData("file") + "' on Sym " + item.getData("loc") + " has been modified, do you want to save it before closing it?");
		else
			dialog.setMessage("The file '" + item.getData("file") + "' in directory " + item.getData("loc") + " has been modified, do you want to save it before closing it?");

		int result = dialog.open();

		if (result == SWT.CANCEL)
			return false;
		else if (result == SWT.YES) {
			((EditorComposite) item.getControl()).saveFile(false);
		}
	}

	if (mainfolder.getSelection().getControl() instanceof EditorComposite)
		for (TableItem tItem : tblErrors.getItems())
			if (tItem.getData("file").equals(mainfolder.getSelection().getData("file")) && tItem.getData("sym").equals(mainfolder.getSelection().getData("sym"))){
				tItem.dispose();
				//EditorCompositeList.remove(mainfolder.getSelection().getControl());
			}
	// Remove entries matching this tab from the tabHistory stack since we are closing the file
	List<CTabItem> closingTab = Arrays.asList(item);
	tabHistory.removeAll(closingTab);
	if(!tabHistory.isEmpty())
		setMainFolderSelection(tabHistory.get(tabHistory.size()-1));
	return true;
}
 
Example 16
Source File: TypeInfoViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void deleteHistoryEntry() {
	int index= fTable.getSelectionIndex();
	if (index == -1)
		return;
	TableItem item= fTable.getItem(index);
	Object element= item.getData();
	if (!(element instanceof TypeNameMatch))
		return;
	if (fHistory.remove(element) != null) {
		item.dispose();
		fItems.remove(index);
		int count= fTable.getItemCount();
		if (count > 0) {
			item= fTable.getItem(0);
			if (item.getData() instanceof DashLine) {
				item.dispose();
				fItems.remove(0);
				fDashLineIndex= -1;
				if (count > 1) {
					setTableSelection(0);
				}
			} else {
				if (index >= count) {
					index= count - 1;
				}
				setTableSelection(index);
			}
		} else {
			// send dummy selection
			fTable.notifyListeners(SWT.Selection, new Event());
		}
	}
}
 
Example 17
Source File: OrderableFieldDialogImpl.java    From jenerate with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Moves an entry in the field table to the given index.
 */
private void move(TableItem item, int index) {
    Object data = item.getData();
    boolean checked = fieldViewer.getChecked(data);
    item.dispose();
    fieldViewer.insert(data, index);
    fieldViewer.setChecked(data, checked);
}
 
Example 18
Source File: DualList.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Cleans the content of a table
 *
 * @param table table to be emptied
 */
private void clean(final Table table) {
	if (table == null) {
		return;
	}

	for (final TableItem item : table.getItems()) {
		item.dispose();
	}
}
 
Example 19
Source File: ViewRisksHIPAAIdentifiersTable.java    From arx with Apache License 2.0 4 votes vote down vote up
@Override
protected void doUpdate(final AnalysisContextRisk context) {
    
    // Enable/disable
    final RiskEstimateBuilderInterruptible builder = getBuilder(context);
    if (!this.isEnabled() || builder == null) {
        if (manager != null) {
            manager.stop();
        }
        this.setStatusEmpty();
        return;
    }
    
    // Create an analysis
    Analysis analysis = new Analysis() {
        
        private boolean stopped = false;
        private HIPAAIdentifierMatch[] matches;
        
        @Override
        public int getProgress() {
            return 0;
        }
        
        @Override
        public void onError() {
            setStatusEmpty();
        }
        
        @Override
        public void onFinish() {
            
            // Check
            if (stopped || !isEnabled()) {
                return;
            }

            // Disable drawing
            table.setRedraw(false);
            
            // Update chart
            for (final TableItem i : table.getItems()) {
                i.dispose();
            }
            
            // For all identifiers
            for (HIPAAIdentifierMatch item : matches) {
                createItem(item);
            }
            
            // Pack columns
            for (final TableColumn col : table.getColumns()) {
                col.pack();
            }

            // Layout
            table.layout();

            // Enable drawing and redraw
            table.setRedraw(true);
            table.redraw();

            // Set status
            setStatusDone();
        }
        
        @Override
        public void onInterrupt() {
            if (!isEnabled() || !isValid()) {
                setStatusEmpty();
            } else {
                setStatusWorking();
            }
        }
        
        @Override
        public void run() throws InterruptedException {
            
            // Timestamp
            long time = System.currentTimeMillis();
            
            // Perform work
            matches = builder.getHIPAAIdentifiers();
            
            // Our users are patient
            while (System.currentTimeMillis() - time < MINIMAL_WORKING_TIME && !stopped) {
                Thread.sleep(10);
            }
        }
        
        @Override
        public void stop() {
            if (builder != null)
                builder.interrupt();
            this.stopped = true;
        }
    };
    
    this.manager.start(analysis);
}
 
Example 20
Source File: ViewRisksQuasiIdentifiersTable.java    From arx with Apache License 2.0 4 votes vote down vote up
@Override
protected void doUpdate(final AnalysisContextRisk context) {
    
    // Enable/disable
    final RiskEstimateBuilderInterruptible builder = getBuilder(context, context.context.getModel().getSelectedQuasiIdentifiers());
    if (!this.isEnabled() || builder == null) {
        if (manager != null) {
            manager.stop();
        }
        this.setStatusEmpty();
        return;
    }

    // Create an analysis
    Analysis analysis = new Analysis() {

        // The statistics builder
        private boolean stopped = false;
        private RiskModelAttributes risks;

        @Override
        public int getProgress() {
            return builder.getProgress();
        }

        @Override
        public void onError() {
            setStatusEmpty();
        }

        @Override
        public void onFinish() {

            if (stopped || !isEnabled()) {
                return;
            }

            // Disable drawing
            table.setRedraw(false);
            
            // Update chart
            for (final TableItem i : table.getItems()) {
                i.dispose();
            }
            
            // Create table items
            for (QuasiIdentifierRisk item : risks.getAttributeRisks()) {
                createItem(item);
            }
            
            // Pack columns
            for (final TableColumn col : table.getColumns()) {
                col.pack();
            }
            
            // Layout
            table.layout();

            // Enable drawing and redraw
            table.setRedraw(true);
            table.redraw();
            table.getParent().pack();

            // Update status
            if (risks.getAttributeRisks().length == 0) {
                setStatusEmpty();
            } else {
                setStatusDone();
            }
        }

        @Override
        public void onInterrupt() {
            if (!isEnabled() || !isValid()) {
                setStatusEmpty();
            } else {
                setStatusWorking();
            }
        }

        @Override
        public void run() throws InterruptedException {
            // Timestamp
            long time = System.currentTimeMillis();
            risks = builder.getAttributeRisks();

            // Our users are patient
            while (System.currentTimeMillis() - time < MINIMAL_WORKING_TIME && !stopped) {
                Thread.sleep(10);
            }
        }

        @Override
        public void stop() {
            if (builder != null) builder.interrupt();
            this.stopped = true;
        }
    };

    this.manager.start(analysis);
}